#include "DiscreteDisplay.h"
#include "DisplayController.h"
#include "History.h"
#include <stdio.h>

#include <QPainter>
#include "Signal.h"

DiscreteDisplay::DiscreteDisplay(Signal* s, QColor color, bool positionIsShared)
	: LMONDisplay(s, color, 30, positionIsShared)
{
}

void DiscreteDisplay::drawSignal(QPaintDevice* pPD)
{
	QPainter painter((QPaintDevice*) pPD);
	QRect nameRect, valueRect;

	QRect linerect = _rect;
	nameRect = painter.boundingRect(linerect, Qt::AlignLeft | Qt::TextSingleLine, _name.c_str());

	QString valueString;
	valueString.sprintf("%2.1f", (double) _pHistory->tail().value );
	valueRect = painter.boundingRect(linerect, Qt::AlignRight, valueString);

	painter.setPen(_color);
//	painter.drawRect(linerect);	
	painter.drawText(nameRect, _name.c_str());
	painter.drawText(valueRect, valueString);
}
